home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / Advanced I⁄O v2.3 / ANSI #includes addenda / istream next >
Text File  |  1996-02-01  |  4KB  |  134 lines

  1. // istream standard header
  2. #ifndef _ISTREAM_
  3. #define _ISTREAM_
  4. #include <streambuf>
  5.  
  6. #if __MWERKS__
  7. #pragma options align=mac68k
  8.  
  9. #if __CFM68K__ && __USING_IMPORTED_ANSI__
  10. #pragma import on
  11. #endif
  12. #endif
  13.  
  14.         // class istream
  15. class istream : virtual public ios {
  16. public:
  17.     istream(streambuf *_S)
  18.         : _Chcount(0) { init(_S); }
  19.     istream(_Uninitialized)
  20.         : ios(_Noinit) {}
  21.     virtual ~istream();
  22.     _Bool ipfx(int = 0);
  23.     void isfx()
  24.         {}
  25.     istream& operator>>(istream& (*_F)(istream&))
  26.         {return ((*_F)(*this)); }
  27.     istream& operator>>(ios& (*_F)(ios&))
  28.         {(*_F)(*(ios *)this); return (*this); }
  29.     istream& operator>>(char *);
  30.     istream& operator>>(unsigned char *_S)
  31.         {return (*this >> (char *)_S); }
  32.     istream& operator>>(char&);
  33.     istream& operator>>(unsigned char& _C)
  34.         {return (*this >> *(char *)&_C); }
  35.     istream& operator>>(short&);
  36.     istream& operator>>(unsigned short&);
  37.     istream& operator>>(int&);
  38.     istream& operator>>(unsigned int&);
  39.     istream& operator>>(long&);
  40.     istream& operator>>(unsigned long&);
  41.     istream& operator>>(float&);
  42.     istream& operator>>(double&);
  43.     istream& operator>>(long double&);
  44.     istream& operator>>(void *&);
  45.     istream& operator>>(streambuf&);
  46.     int get();
  47.     istream& get(char *, int, char = '\n');
  48.     istream& get(unsigned char *_S, int _N, char _D = '\n')
  49.         {return(get((char *)_S, _N, _D)); }
  50.     istream& get(char&);
  51.     istream& get(unsigned char& _C)
  52.         {return (get((char&)_C)); }
  53.     istream& get(streambuf&, char = '\n');
  54.     istream& getline(char *, int, char = '\n');
  55.     istream& getline(unsigned char *_S, int _N, char _D = '\n')
  56.         {return(getline((char *)_S, _N, _D)); }
  57.     istream& ignore(int = 1, int = EOF);
  58.     istream& read(char *, int);
  59.     istream& read(unsigned char *_S, int _N)
  60.         {return(read((char *)_S, _N)); }
  61.     int peek();
  62.     istream& putback(char);
  63.     istream& unget();
  64.     int gcount() const
  65.         {return (_Chcount); }
  66.     int sync();
  67.  streampos tellg(void)
  68.   { streampos pos = rdbuf()->pubseekoff(0, ios::cur, ios::in);
  69.     if( pos == streampos(EOF) )
  70.       setstate(ios::badbit);
  71.     return pos;
  72.   }
  73. istream& seekg(streamoff off, ios::seekdir dir)
  74. {
  75.   streampos pos = rdbuf()->pubseekoff(off,dir,ios::in);
  76.   if (pos == streampos(EOF))
  77.     setstate(ios::badbit);
  78.   return *this;
  79. }
  80. istream& seekg(streampos pos)
  81. {
  82.     pos = rdbuf()->pubseekpos(pos, ios::in);
  83.     if (pos == streampos(EOF))
  84.         setstate(ios::badbit);
  85.     return *this;
  86. }
  87. #if _HAS_SIGNED_CHAR
  88.     istream& operator>>(signed char *_S)
  89.         {return (*this >> (char *)_S); }
  90.     istream& operator>>(signed char& _C)
  91.         {return (*this >> *(char *)&_C); }
  92.     istream& get(signed char *_S, int _N, char _D = '\n')
  93.         {return (get((char *)_S, _N, _D)); }
  94.     istream& get(signed char& _C)
  95.         {return (get((char&)_C)); }
  96.     istream& getline(signed char *_S, int _N, char _D = '\n')
  97.         {return (getline((char *)_S, _N, _D)); }
  98.     istream& read(signed char *_S, int _N)
  99.         {return (read((char *)_S, _N)); }
  100. #endif /* _HAS_SIGNED_CHAR */
  101. protected:
  102.     int _Getffld(char [_MAX_EXP_DIG + _MAX_SIG_DIG + 16]);
  103.     int _Getifld(char [_MAX_INT_DIG], _Bool = 0);
  104. private:
  105.     int _Chcount;
  106.     };
  107.         // manipulators
  108. istream& ws(istream&);
  109.  
  110. #if __MWERKS__
  111. #if __CFM68K__ && __USING_IMPORTED_ANSI__
  112. #pragma import reset
  113. #endif
  114.  
  115. #pragma options align=reset
  116. #endif
  117.  
  118. #endif
  119.  
  120. /*
  121.  * Copyright (c) 1994 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  122.  * Consult your license regarding permissions and restrictions.
  123.  */
  124.  
  125. /* Change log:
  126.  * 1994-06-04: PlumHall baseline
  127.  * 1994-09-30: Applied diffs for Fri Aug 26 00:51:20 1994
  128.  * 1994-10-07: Inserted MW changes.
  129.  * 1994-10-14: XL04 change istream(streambuf *_S) to init derived 
  130.  */
  131.  
  132. /* Change log:
  133.  */
  134.